package com.work.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.work.bean.PestsBean;
import com.work.mapper.PestsMapper;
import com.work.service.IPestsService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Service
@Transactional
public class IPestsServiceImpl extends ServiceImpl<PestsMapper, PestsBean> implements IPestsService {
    @Resource
    private PestsMapper mapper;

    @Override
    public Page<PestsBean> findByItem(Integer pageNo, Integer pageSize, String pestsName, String hostName) {
        Page<PestsBean> page = new Page<>(pageNo, pageSize);
        QueryWrapper wrapper = new QueryWrapper();
        if(pestsName!=null && !pestsName.equals("")){
            wrapper.like("pests_name", pestsName);
        }if(hostName!=null && !hostName.equals("")){
            wrapper.like("pests_host", hostName);
        }
        mapper.selectPage(page, wrapper);

        return page;
    }
}
